import java.util.*;

public class Answer3 {
    //字母收集
    //https://www.nowcoder.com/practice/9740ce2df0a04399a5ade1927d34c1e1?tpId=230&tqId=38954&ru=/exam/oj
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            int m = in.nextInt();


            char[][] arr = new char[n + 1][m + 1];
            for (int i = 1; i <= n; i++) {
                char[] s = in.next().toCharArray();
                for (int j = 1; j <= m; j++) {
                    arr[i][j] = s[j - 1];
                }
            }

            int[][] dp = new int[n + 1][m + 1];
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= m; j++) {
                    int point = 0;
                    switch (arr[i][j]) {
                        case 'l':
                            point = 4;
                            break;
                        case 'o':
                            point = 3;
                            break;
                        case 'v':
                            point = 2;
                            break;
                        case 'e':
                            point = 1;
                            break;
                    }
                    dp[i][j] = Math.max(dp[i][j - 1], dp[i - 1][j]) + point;
                }
            }

            System.out.println(dp[n][m]);
        }
    }
}
